using System.Collections;
using Microsoft.VisualBasic;

namespace CSharpPro._1014;

public class Demo
{
    /*
    public void TestPrint()
    {
        int[] arr=new int[5];
        arr[0]=1;
        arr[1]=2;
        arr[2]=3;   
        arr[3]=4;
        arr[4]=5;
        Console.WriteLine(arr[2]);
        int[] arr2=new int[]{1,40,9,5,7};
        
        int[,] arr3=new int[5,6];
        string[] arr4=new string[5];
        Array.Sort(arr2);
        Array.Reverse(arr2);

        foreach (var VARIABLE in arr2)
        {
            Console.WriteLine(VARIABLE);
        }
        
        ArrayList list=new ArrayList();
        
        Hashtable ht=new Hashtable();
        ht.Add(1,2);
        ht.Add(2,3);
        foreach (var VARIABLE in ht)
        {
            Console.WriteLine(VARIABLE);
        }
    }*/

    //冒泡排序
    public void TestPrint2()
    {
        //从小到大
        int[] arr = new int[] { 5, 6, 9, 11, 2 };
        int n=arr.Length;
        for (int i = 0; i < n - 1; i++)
        {
            for (int j = 0; j < n - 1 - i; j++)
            {
                if (arr[j] > arr[j + 1])
                {
                    int temp = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = temp;
                    
                }
            }
        }

        for (int i = 0; i < n; i++)
        {
            Console.Write(arr[i]);
            Console.Write(" ");
        } 
    }
}